﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using BBServer20210601.Pages;
using ECharts.Net.ChartSeries;
using ECharts.Net;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Unicode;
using WalkingTec.Mvvm.Mvc.Binders;

namespace LayuiDemo.demo.ViewModels.FooVMs
{
	public partial class FooVM : BaseCRUDVM<Foo>
	{
		public string ChartString { get; set; }
		public FooVM()
		{
			JsonHelper.Configure = (a) =>
			{
				a.WriteIndented = false;
				a.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
			};
		}

		protected override void InitVM()
		{
			ChartPieSeries cps = new ChartPieSeries();
			cps.name = "pie demo";
			cps.radius = 90;
			cps.startAngle = 300;
			cps.type = "pie";

			ChartSeriesData csd_pc = new ChartSeriesData();
			csd_pc.name = "电脑";
			csd_pc.value = "23";

			ChartSeriesData csd_phone = new ChartSeriesData();
			csd_phone.name = "手机";
			csd_phone.value = "88";

			List<object> data = new List<object>();
			data.Add(csd_pc);
			data.Add(csd_phone);

			cps.data = data;

			List<string> legend = new List<string>(4);
			legend.Add("电脑");
			legend.Add("手机");

			List<ChartPieSeries> cpss = new List<ChartPieSeries>();
			cpss.Add(cps);

			ChartString = ChartOpertation.ChartPieDataProcess(cpss, legend, true, "pie demo", "subtext", true);
		}

		public override void DoAdd()
		{
			base.DoAdd();
		}

		public override void DoEdit(bool updateAllFields = false)
		{
			base.DoEdit(updateAllFields);
		}

		public override void DoDelete()
		{
			base.DoDelete();
		}
	}
}
